﻿/*                              
   Copyright 2011 Nils Kopal, Christopher Krüger, Simone Sauer, Dennis Nolte, Uni Duisburg-Essen

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
using System;
using Sharebert.OverlayLibrary.Messages;

namespace Sharebert.OverlayLibrary.API
{
    /// <summary>
    /// Provides an easy to use interface to other peers.
    /// </summary>
    public interface IConnectionHandler
    {

        /// <summary>
        /// Sends a message to the peer with the given recipientID and the given payload.
        /// </summary>
        /// <param name="senderID">PeerID of the sender</param>
        /// <param name="recipientID">PeerID of the recipient</param>
        /// <param name="messageType">The message type</param>
        /// <param name="payload">The payload of this message</param>
        /// <exception cref="Sharebert.NetworkLayerLibrary.SerializationException">Serialization of the search results failed</exception>
        /// <exception cref="Sharebert.NetworkLayerLibrary.NetworkException">Error while sending the search results</exception>
        void SendMessage(byte[] senderID, byte[] recipientID, string messageType, byte[] payload);

        /// <summary>
        /// Closes the underlying connection.
        /// </summary>
        void Disconnect();

        /// <summary>
        /// The IP address of the remote client.
        /// </summary>
        string RemoteIP { get; }

        /// <summary>
        /// The port of the remote client.
        /// </summary>
        int RemotePort { get; }

        /// <summary>
        /// The IP address of the local client.
        /// </summary>
        string LocalIP { get; }

        /// <summary>
        /// The port of the local client.
        /// </summary>
        int LocalPort { get; }

    }
}
